/**
 * 
 */
package x.java.util.jar;

import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;

/**
 * @author qiangli
 * 
 */
public class JarFile extends java.util.jar.JarFile {
	private x.java.io.File file = null;

	/**
	 * @param name
	 * @throws IOException
	 */
	public JarFile(String name) throws IOException {
		this(new x.java.io.File(name), true, ZipFile.OPEN_READ);
	}

	/**
	 * @param file
	 * @throws IOException
	 */
	public JarFile(File file) throws IOException {
		this((x.java.io.File)file, true, ZipFile.OPEN_READ);
	}

	/**
	 * @param name
	 * @param verify
	 * @throws IOException
	 */
	public JarFile(String name, boolean verify) throws IOException {
		this(new x.java.io.File(name), verify, ZipFile.OPEN_READ);
	}

	/**
	 * @param file
	 * @param verify
	 * @throws IOException
	 */
	public JarFile(File file, boolean verify) throws IOException {
		this((x.java.io.File)file, verify, ZipFile.OPEN_READ);
	}

	/**
	 * @param file
	 * @param verify
	 * @param mode
	 * @throws IOException
	 */
	public JarFile(File file, boolean verify, int mode) throws IOException {
		this((x.java.io.File)file, verify, mode);
	}

	private JarFile(x.java.io.File file, boolean verify, int mode) throws IOException {
		super(file.replicate(), verify, mode);
		this.file = file;
	}
	
	public void close() throws IOException {
		super.close();
		new java.io.File(super.getName()).delete();
	}

	public String getName() {
		return file.getPath();
	}
}
